{extend name="base"/}
{block name="main"}
<div class="Hui-article">
    <article class="cl pd-20">
        <div class="n_tab_line">
            <a href="{:url('Config/indexModule')}" class="n_tab_list">模块列表</a>
            <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px;display: none;" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
            <div class="cl"></div>
        </div>
        <table class="table table-border table-bordered table-hover table-bg">
            <thead>
            <tr>
                <th scope="col" colspan="9">模块列表</th>
            </tr>
            <tr class="text-c">
                <th>排序</th>
                <th>名称</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="list" id="vo"}
            <tr class="text-c">
                <td><input type="number" value="{$vo['sort']}" style="width: 30px;text-align: center" onchange="mod_sort(this.value,'{$vo.id}')"></td>
                <td>{$vo['name']}</td>
                <td>
                    {if $vo['is_use']==0}
                    <span class="label label-default radius">未启用</span>
                    {else}
                    <span class="label label-success radius">已启用</span>
                    {/if}
                </td>
                <td class="td-manage">
                    {if $vo['is_use']==0}
                    <a title="启用" href="javascript:;" onclick="mod_start('{$vo.id}')" class="ml-5" style="text-decoration:none"><i style="font-size: 25px" class="Hui-iconfont">&#xe6e1;</i></a>
                    {else}
                    <a title="禁用" href="javascript:;" onclick="mod_stop('{$vo.id}')" class="ml-5" style="text-decoration:none"><i style="font-size: 25px"  class="Hui-iconfont">&#xe706;</i></a>
                    {/if}
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </article>
    <div class="n_page_no">
        {$page}
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    /*
     参数解释：
     title	标题
     url		请求的url
     id		需要操作的数据id
     w		弹出层宽度（缺省调默认值）
     h		弹出层高度（缺省调默认值）
     */
    /*模块-停用*/
    function mod_stop(id){
        layer.confirm('确认要停用吗？',function(index){
            //此处请求后台程序，下方是成功后的处理……
            //后台处理
            $.ajax({
                type : "post",
                url : "{:url('config/indexModuleOff')}",
                data : {
                    "id" : id,
                },
                success : function(data) {
                    if (data['code'] > 0) {
                        layer.msg('已停用!',{icon: 5,time:1000},function () {
                            window.location.reload();
                        });
                    }else{
                        layer.msg(data['message'], {icon: 2, time: 1000});
                    }
                }
            })
        });
    }
    /*模块-启用*/
    function mod_start(id){
        layer.confirm('确认要启用吗？',function(index){
            //此处请求后台程序，下方是成功后的处理……
            //后台处理
            $.ajax({
                type : "post",
                url : "{:url('config/indexModuleOn')}",
                data : {
                    "id" : id,
                },
                success : function(data) {
                    if (data['code'] > 0) {
                        layer.msg('已启用!', {icon: 6,time:1000},function () {
                            window.location.reload();
                        });
                    }else{
                        layer.msg(data['message'], {icon: 2, time: 1000});
                    }
                }
            })
        });
    }
    /*模块-排序*/
    function mod_sort(val,id){
            $.ajax({
                type : "post",
                url : "{:url('config/indexModuleSort')}",
                data : {
                    "sort" : val,
                    "id" : id,
                },
                success : function(data) {
                    if (data['code'] > 0) {
                        layer.msg('设置成功!',{icon: 1,time:1000},function () {
                            window.location.reload();
                        });
                    }else{
                        layer.msg(data['message'], {icon: 2, time: 1000});
                    }
                }
            })
    }
</script>
{/block}